<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ContactForm
 *
 * @author jay
 */
class ContactForm extends BaseForm {

    public function configure() {
        $w = new sfWidgetFormInputText();
        $w->setLabel('Name');
        $this->setWidget('name', $w);

        $w = new sfWidgetFormInputText();
        $w->setLabel('Email');
        $this->setWidget('email', $w);

        $w = new sfWidgetFormInputText();
        $w->setLabel('Phone');
        $this->setWidget('phone', $w);

        $contactRegardingOptions = array();
        foreach (sfConfig::get('app_contact_regarding_options') as $rOption) {
            $contactRegardingOptions[$rOption] = $rOption;
        }
        

        $w = new sfWidgetFormChoice(array('choices' => $contactRegardingOptions, 'expanded' => true, 'multiple' => false));
        $w->setLabel('Regarding');
        $this->setWidget('regarding', $w);


        $w = new sfWidgetFormTextarea();
        $w->setLabel('Message');
        $this->setWidget('message', $w);



        $this->setValidators(array(
            'name' => new sfValidatorString(array('min_length' => 1, 'max_length' => 40)),
            'email' => new sfValidatorEmail(),
            'phone' => new sfValidatorPass(),
            'message' => new sfValidatorString(array('min_length' => 1, 'max_length' => 1000)),
            'message' => new sfValidatorString(array('min_length' => 1, 'max_length' => 1000)),
            'regarding' => new sfValidatorChoice(array('choices' => $contactRegardingOptions))
        ));

        $this->widgetSchema->setNameFormat('contact[%s]');

        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
    }

}

?>
